package org.msb.code.thread;

/**
 * @Package org.msb.code.thread
 * @PROJECT_NAME: question
 * @DESCRIPTION:
 * @USER: zhuchenglin
 * @DATE: 2022/6/3 21:44
 */
public class TestSortPrint {
    public static void main(String[] args) {
        // 要求线程顺序打印A1B2C3....Z26
        TestSortPrint t = new TestSortPrint();
        new Thread(() -> {
            t.test2();
        }).start();

        new Thread(() -> {
            t.test1();
        }).start();
    }

    public synchronized void test1(){
        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("执行1");
    }

    public synchronized void test2(){
        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("执行2");
    }
}
